home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
cenvid
/
controlc.lib
< prev
next >
Wrap
Text File
|
1995-01-31
|
2KB
|
53 lines
// ControlC.lib - Install CEnvi for DOS 1.009 handler for Ctrl-C
// ver.1 and Ctrl-Break pressed at the keyboard.
//
// InstallBreakHandler() - Installs break handler to catch ctrl-C
// or ctrl-break handling. Sets the
// gCtrlBreak global to True.
// RemoveBreakHandler() - Remove control break handler
//
// gCtrlBreak; Global value set to True if Ctrl-C <CtrlBreak>
// handler is called. You can check this flag to
// see if break was pressed and handle however you
// wish.
gCtrlBreak = False;
gBreakHandlerInstalled = False;
gOriginalInterrupt23h = 0;
gAsmCode = "\x1E\x57\xBF\x00\x00\x8E\xDF\xBF\x00\x00\xC6\x05\x01\x5F\x1F\xCF";
// PUSH DS
// PUSH DI
// MOV DI,0000
// MOV DS,DI
// MOV DI,0000
// MOV BYTE PTR [DI],01
// POP DI
// POP DS
// IRET
gCLI = "\xFA\xCB";
gSTI = "\xFB\xCB";
atexit("RemoveBreakHandler");
InstallBreakHandler()
{
gBreakHandlerInstalled = True;
BLObPut(gAsmCode,3,segment(pointer(gCtrlBreak)),UWORD16);
BLObPut(gAsmCode,8,offset(pointer(gCtrlBreak)),UWORD16);
asm(gCLI);
gOriginalInterrupt23h = peek(4*0x23,UWORD32);
poke(4*0x23,pointer(gAsmCode),UWORD32);
asm(gSTI);
}
RemoveBreakHandler()
{
if ( gBreakHandlerInstalled ) {
gBreakHandlerInstalled = False;
asm(gCLI);
poke(4*0x23,gOriginalInterrupt23h,UWORD32);
asm(gSTI);
}
}